﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace GanoESB
{
    public class Bindings
    {
        private NetTcpBinding tcpBinding;
        private NetNamedPipeBinding pipeBinding;
        private BasicHttpBinding httpBinding;

        public Bindings()
        {
            tcpBinding = new NetTcpBinding();
            tcpBinding.PortSharingEnabled = true; // 共享端口
            tcpBinding.MaxReceivedMessageSize = int.MaxValue;
            tcpBinding.MaxBufferSize = int.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            tcpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            tcpBinding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
            tcpBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
            tcpBinding.Security.Mode = SecurityMode.None;

            pipeBinding = new NetNamedPipeBinding();
            pipeBinding.MaxReceivedMessageSize = int.MaxValue;
            pipeBinding.MaxBufferSize = int.MaxValue;
            pipeBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            pipeBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            pipeBinding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
            pipeBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;

            httpBinding = new BasicHttpBinding();
            httpBinding.MaxReceivedMessageSize = int.MaxValue;
            httpBinding.MaxBufferSize = int.MaxValue;
            httpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            httpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            httpBinding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
            httpBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
        }

        public NetTcpBinding TcpBinding
        {
            get { return tcpBinding; }
        }

        public NetNamedPipeBinding PipeBinding
        {
            get { return pipeBinding; }
        }

        public BasicHttpBinding HttpBinding
        {
            get { return httpBinding; }
        }
    }
}
